#ifndef __CXVENC_SDK_H__
#define __CXVENC_SDK_H__


typedef enum
{
	CXVENC_SDK_PIXEL_FORMAT_YUV420_PLANAR,
	CXVENC_SDK_PIXEL_FORMAT_YUV420_SEMIPLANAR,
	CXVENC_SDK_PIXEL_FORMAT_INTERLEAVED_YUYV,
	CXVENC_SDK_PIXEL_FORMAT_INTERLEAVED_UYVY,
}CXVENC_SDK_PIXEL_FORMAT;


typedef enum
{
	CXVENC_SDK_INPUT_V4L2,
	CXVENC_SDK_INPUT_V4L2_NO_WORK_THREAD,
	CXVENC_SDK_INPUT_USER_CALLBACK,
	CXVENC_SDK_INPUT_USER_PUT,
}CXVENC_SDK_INPUT_TYPE;

typedef enum
{
	CXVENC_SDK_STREAM_MAIN,
	CXVENC_SDK_STREAM_SUB,
}CXVENC_SDK_STREAM_TYPE;

#ifdef __cplusplus
extern "C"
{
#endif


typedef void * cxvenc_sdk_get_input_image(void * user_ptr , unsigned * p_image_bus_addr);
typedef void cxvenc_sdk_image_captured(void * user_ptr , unsigned frame_num , unsigned time_stamp , 
									   unsigned char * image_data , 
									   unsigned image_bus_addr);
typedef void cxvenc_sdk_image_encoded(void * user_ptr , CXVENC_SDK_STREAM_TYPE stream_type , 
									 unsigned frame_num , unsigned time_stamp , unsigned len , 
									 unsigned char * encoded_data);

void *  cxvenc_sdk_init(CXVENC_SDK_INPUT_TYPE input_type , char * v4l2drv_name ,
						 cxvenc_sdk_get_input_image * input_cb , 
						cxvenc_sdk_image_captured * capture_cb ,
						cxvenc_sdk_image_encoded * output_cb , void * user_ptr , 
						unsigned main_width , unsigned main_height , 
						CXVENC_SDK_PIXEL_FORMAT pixel_fmt , unsigned main_input_fps , unsigned main_enc_fps , 
						unsigned main_bitrate , unsigned main_gop , 
						unsigned sub_width , unsigned sub_height , 
						unsigned sub_enc_fps , unsigned sub_bitrate , unsigned sub_gop , unsigned jpg_q);
						

void cxvenc_sdk_release(void * handle);

void cxvenc_sdk_start(void * handle);

void cxvenc_sdk_stop(void * handle);

void cxvenc_sdk_capture_and_encode_v4l2_image(void * handle);

void cxvenc_sdk_encode_image(void * handle , unsigned char * image_data , unsigned image_bus_addr);

void cxvenc_sdk_set_bitrate_and_gop(void * handle , CXVENC_SDK_STREAM_TYPE stream_type , 
								   int bitrate , int gop);

void cxvenc_sdk_set_input_fps(void * handle , int fps);
void cxvenc_sdk_set_encode_fps(void * handle , CXVENC_SDK_STREAM_TYPE stream_type , int fps);

void * cxvenc_sdk_capture_cur_image_to_jpg(void * handle , int q , unsigned * p_len);

void cxvenc_sdk_force_output_I_frame(void * handle , CXVENC_SDK_STREAM_TYPE stream_type);

#ifdef __cplusplus
}
#endif


#endif
